package com.kexio.pay.entity;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kexio.common.entity.BaseEntity;

/**
 * 退款订单
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
@TableName("pay_refund")
public class RefundOrder extends BaseEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 退款单号 (系统生成)
     */
    @TableField("refund_no")
    private String refundNo;
    
    /**
     * 原支付订单号
     */
    @TableField("order_no")
    private String orderNo;
    
    /**
     * 原支付订单ID
     */
    @TableField("payment_order_id")
    private String paymentOrderId;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;
    
    /**
     * 退款金额
     */
    @TableField("refund_amount")
    private BigDecimal refundAmount;
    
    /**
     * 原订单金额
     */
    @TableField("total_amount")
    private BigDecimal totalAmount;
    
    /**
     * 退款原因
     */
    @TableField("refund_reason")
    private String refundReason;
    
    /**
     * 退款状态
     */
    @TableField("status")
    private String status;
    
    /**
     * 第三方退款单号
     */
    @TableField("third_party_refund_no")
    private String thirdPartyRefundNo;
    
    /**
     * 第三方退款流水号
     */
    @TableField("third_party_refund_id")
    private String thirdPartyRefundId;
    
    /**
     * 申请时间
     */
    @TableField("apply_time")
    private LocalDateTime applyTime;
    
    /**
     * 退款成功时间
     */
    @TableField("success_time")
    private LocalDateTime successTime;
    
    /**
     * 退款失败时间
     */
    @TableField("fail_time")
    private LocalDateTime failTime;
    
    /**
     * 处理时间 (第三方返回)
     */
    @TableField("process_time")
    private LocalDateTime processTime;
    
    /**
     * 错误码
     */
    @TableField("error_code")
    private String errorCode;
    
    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;
    
    /**
     * 退款渠道 (ORIGINAL-原路退回, BALANCE-退回余额)
     */
    @TableField("refund_channel")
    private String refundChannel;
    
    /**
     * 退款账户信息
     */
    @TableField("refund_account")
    private String refundAccount;
    
    /**
     * 操作员ID (管理员退款)
     */
    @TableField("operator_id")
    private String operatorId;
    
    /**
     * 操作员名称
     */
    @TableField("operator_name")
    private String operatorName;
    
    /**
     * 扩展信息 (JSON格式)
     */
    @TableField("extra_data")
    private String extraData;
    
    /**
     * 通知次数
     */
    @TableField("notify_count")
    private Integer notifyCount;
    
    /**
     * 最后通知时间
     */
    @TableField("last_notify_time")
    private LocalDateTime lastNotifyTime;
    
    // Constructors
    public RefundOrder() {}
    
    public RefundOrder(String refundNo, String orderNo, String paymentOrderId, String userId,
                      BigDecimal refundAmount, BigDecimal totalAmount, String refundReason) {
        this.refundNo = refundNo;
        this.orderNo = orderNo;
        this.paymentOrderId = paymentOrderId;
        this.userId = userId;
        this.refundAmount = refundAmount;
        this.totalAmount = totalAmount;
        this.refundReason = refundReason;
        this.status = "PENDING";
        this.applyTime = LocalDateTime.now();
        this.refundChannel = "ORIGINAL";
        this.notifyCount = 0;
    }
    
    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    
    public String getRefundNo() { return refundNo; }
    public void setRefundNo(String refundNo) { this.refundNo = refundNo; }
    
    public String getOrderNo() { return orderNo; }
    public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
    
    public String getPaymentOrderId() { return paymentOrderId; }
    public void setPaymentOrderId(String paymentOrderId) { this.paymentOrderId = paymentOrderId; }
    
    public String getUserId() { return userId; }
    public void setUserId(String userId) { this.userId = userId; }
    
    public BigDecimal getRefundAmount() { return refundAmount; }
    public void setRefundAmount(BigDecimal refundAmount) { this.refundAmount = refundAmount; }
    
    public BigDecimal getTotalAmount() { return totalAmount; }
    public void setTotalAmount(BigDecimal totalAmount) { this.totalAmount = totalAmount; }
    
    public String getRefundReason() { return refundReason; }
    public void setRefundReason(String refundReason) { this.refundReason = refundReason; }
    
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    
    public String getThirdPartyRefundNo() { return thirdPartyRefundNo; }
    public void setThirdPartyRefundNo(String thirdPartyRefundNo) { this.thirdPartyRefundNo = thirdPartyRefundNo; }
    
    public String getThirdPartyRefundId() { return thirdPartyRefundId; }
    public void setThirdPartyRefundId(String thirdPartyRefundId) { this.thirdPartyRefundId = thirdPartyRefundId; }
    
    public LocalDateTime getApplyTime() { return applyTime; }
    public void setApplyTime(LocalDateTime applyTime) { this.applyTime = applyTime; }
    
    public LocalDateTime getSuccessTime() { return successTime; }
    public void setSuccessTime(LocalDateTime successTime) { this.successTime = successTime; }
    
    public LocalDateTime getFailTime() { return failTime; }
    public void setFailTime(LocalDateTime failTime) { this.failTime = failTime; }
    
    public LocalDateTime getProcessTime() { return processTime; }
    public void setProcessTime(LocalDateTime processTime) { this.processTime = processTime; }
    
    public String getErrorCode() { return errorCode; }
    public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
    
    public String getErrorMessage() { return errorMessage; }
    public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
    
    public String getRefundChannel() { return refundChannel; }
    public void setRefundChannel(String refundChannel) { this.refundChannel = refundChannel; }
    
    public String getRefundAccount() { return refundAccount; }
    public void setRefundAccount(String refundAccount) { this.refundAccount = refundAccount; }
    
    public String getOperatorId() { return operatorId; }
    public void setOperatorId(String operatorId) { this.operatorId = operatorId; }
    
    public String getOperatorName() { return operatorName; }
    public void setOperatorName(String operatorName) { this.operatorName = operatorName; }
    
    public String getExtraData() { return extraData; }
    public void setExtraData(String extraData) { this.extraData = extraData; }
    
    public Integer getNotifyCount() { return notifyCount; }
    public void setNotifyCount(Integer notifyCount) { this.notifyCount = notifyCount; }
    
    public LocalDateTime getLastNotifyTime() { return lastNotifyTime; }
    public void setLastNotifyTime(LocalDateTime lastNotifyTime) { this.lastNotifyTime = lastNotifyTime; }
}
